home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ML_BME1.ZIP / ROTATE / V4 / ROTASM3.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-10-29  |  5.3 KB  |  198 lines

  1. ; Bitmap rotation engine, v3.0
  2. ; by Maple Leaf, 22 Oct 96
  3. ;
  4. ; This version deals with 256x256 bitmaps !
  5. ; --------------------------------------------------------------------------
  6. ; Two times smaller than the 320x200 version, and almost two times faster!
  7. ; (take a look at the differences between this version and the previous one)
  8. ; --------------------------------------------------------------------------
  9. ; asm rules, yup yup! the others suck!
  10.  
  11. .model TPascal
  12. .386
  13. .DATA
  14.  
  15.         extrn    _Ax_ : WORD
  16.         extrn    _Ay_ : WORD
  17.         extrn    _Bx_ : WORD
  18.         extrn    _By_ : WORD
  19.         extrn    _Cx_ : WORD
  20.         extrn    _Cy_ : WORD
  21.         extrn    vScr:WORD
  22.         extrn    Img:DWORD
  23.         extrn    Angle:BYTE
  24.         extrn    WW:WORD
  25.         extrn    WH:WORD
  26.         extrn    CosTab:BYTE
  27.         extrn    SinTab:BYTE
  28.  
  29. .CODE
  30.  
  31.         public   GenFrame
  32.  
  33. include jumps.inc
  34.  
  35. ;****************************************************************************
  36.  
  37. proc    ComputeFramePara near
  38.  
  39.         movzx    ax,Angle
  40.         mov      si,ax
  41.         add      al,64     ; Angle+90 in a 360-deg system
  42.         mov      di,ax
  43.  
  44.         add      si,si
  45.         add      di,di     ; indexes in SinTab/CosTab
  46.  
  47.         mov      ax,WH
  48.         xor      dx,dx
  49.         mov      cx,word ptr CosTab[si]
  50.         imul     cx
  51.         shrd     ax,dx,8
  52.         add      ax,_Ax_   ; ax = _ax_ + WH * cos (angle)
  53.         mov      _Bx_,ax   ; store result
  54.  
  55.         mov      ax,WH
  56.         xor      dx,dx
  57.         mov      cx,word ptr SinTab[si]
  58.         imul     cx
  59.         shrd     ax,dx,8
  60.         sub      ax,_Ay_
  61.         neg      ax       ; ax = _ay_ - WH * sin (angle)
  62.         mov      _By_,ax  ; store result
  63.  
  64.         mov      ax,WW
  65.         xor      dx,dx
  66.         mov      cx,word ptr CosTab[di]
  67.         imul     cx
  68.         shrd     ax,dx,8
  69.         add      ax,_Ax_  ; ax = _ax_ + WW * cos (angle+90)
  70.         mov      _Cx_,ax  ; store result
  71.  
  72.         mov      ax,WW
  73.         xor      dx,dx
  74.         mov      cx,word ptr SinTab[di]
  75.         imul     cx
  76.         shrd     ax,dx,8
  77.         sub      ax,_Ay_
  78.         neg      ax       ; eax = _ay_ - WW * sin (angle+90)
  79.         mov      _Cy_,ax  ; store result
  80.  
  81.         ;
  82.  
  83.         mov      ax,_Cx_
  84.         sub      ax,_Ax_
  85.         cwd
  86.         mov      dh,dl   ;
  87.         mov      dl,ah   ; shld dx,ax,8
  88.         mov      ah,al   ;
  89.         mov      al,0    ; shl ax,8
  90.         mov      cx,320
  91.         idiv     cx      ; hAdvX = ((_cx_-_ax_) shl 8) div 320
  92.         mov      word ptr cs:smc1+1,ax  ; SMCODE INIT
  93.  
  94.         mov      ax,_Cy_
  95.         sub      ax,_Ay_
  96.         cwd
  97.         mov      dh,dl   ;
  98.         mov      dl,ah   ; shld dx,ax,8
  99.         mov      ah,al   ;
  100.         mov      al,0    ; shl ax,8
  101.         mov      cx,320
  102.         idiv     cx      ; hAdvY = ((_cy_-_ay_) shl 16) div 320
  103.         mov      word ptr cs:smc2+1,ax  ; SMCODE INIT
  104.  
  105.         mov      ax,_Bx_
  106.         sub      ax,_Ax_
  107.         cwd
  108.         mov      dh,dl   ;
  109.         mov      dl,ah   ; shld dx,ax,8
  110.         mov      ah,al   ;
  111.         mov      al,0    ; shl ax,8
  112.         mov      cx,200
  113.         idiv     cx      ; vAdvX = ((_bx_-_ax_) shl 16) div 200
  114.         mov      word ptr cs:smc3+1,ax  ; SMCODE INIT
  115.  
  116.         mov      ax,_By_
  117.         sub      ax,_Ay_
  118.         cwd
  119.         mov      dh,dl   ;
  120.         mov      dl,ah   ; shld dx,ax,8
  121.         mov      ah,al   ;
  122.         mov      al,0    ; shl ax,8
  123.         mov      cx,200
  124.         idiv     cx      ; vAdvY = ((_by_-_ay_) shl 16) div 200
  125.         mov      word ptr cs:smc4+2,ax  ; SMCODE INIT
  126.  
  127.         retn
  128.         endp
  129.  
  130. ;****************************************************************************
  131.  
  132. GenFrame PROC    NEAR
  133.  
  134.         push     ds es si bp
  135.  
  136. ;       pusha    ; in my example I don't need such sober instructions... :)
  137.                  ; but if the registers are vital to your application, feel
  138.                  ; free to erase the comment (see POPA, too!)
  139.  
  140.         call     ComputeFramePara
  141.  
  142.         mov      es,vScr
  143.         xor      di,di
  144.  
  145. smc1:   mov      bp,1234h  ;hAdvX
  146. smc2:   mov      si,1234h  ;hAdvY
  147.  
  148.         mov      ah,byte ptr _Ax_    ;  starting coordinates
  149.         mov      dh,byte ptr _Ay_    ;
  150.  
  151.         mov      al,0
  152.         mov      dl,al
  153.  
  154.         mov      ds,Img[2]  ; bitmap seg (from this point on)
  155.  
  156. ;-- Loop 1 (200 times) ------------------------------------------------------
  157.         mov      cx,200
  158.  
  159. Loop1:  push     cx
  160.         push     ax dx
  161.  
  162. ;-- Loop 2 (320 times) ------------------------------------------------------
  163.         mov      cx,320
  164.  
  165. Loop2:  mov      bl,ah    ; X coord
  166.         mov      bh,dh    ; Y coord
  167.         mov      bl,[bx]
  168.         mov      es:[di],bl
  169.         inc      di
  170.         add      ax,bp    ; Horizontal-Advance-X factor
  171.         add      dx,si    ; Horizontal-Advance-Y factor
  172.         dec      cx
  173.         sjg      Loop2
  174.  
  175. ;-- End loop 2 --------------------------------------------------------------
  176.  
  177.         pop      dx ax
  178.         pop      cx
  179.  
  180. smc3:   add      ax,1234h ;vAdvX
  181. smc4:   add      dx,1234h ;vAdvY
  182.  
  183.         dec      cx
  184.         jg       Loop1
  185.  
  186. ;-- End loop 1---------------------------------------------------------------
  187.  
  188. ;       popa
  189.  
  190.         pop      bp si es ds
  191.  
  192.         retn
  193.  
  194.         endp
  195.  
  196.  
  197.         END
  198.